<?php

namespace ztn\iot\sdk\util;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/9
 * Time: 15:31
 */
class HttpTool
{
    /**
     * Created by PhpStorm.
     * User: Administrator
     * Date: 2021/12/9
     * Time: 15:24
     */
    public static $BASE_URL = "http://core.ztn-tech.com/";

    public static $token = "";

    public static function doPost($path, $json)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, HttpTool::$BASE_URL . $path);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json; charset=utf-8',
                'access-token: ' . HttpTool::$token
            )
        );
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
}